<?php include("db/connect.php"); 
$sqlselectmaterial="select * from material";
$querymaterial=mysql_query($sqlselectmaterial);

?>

<form id="frmstruc" name="form1" method="post" action="Javascript:insertstruc();">
  <table width="200" border="1">
    <tr>
      <td>ชื่อวัตถุดิบ</td>
      <td>
        <select name="mat_id" id="mat_id">
        <?php 
	while($resultmaterial=mysql_fetch_array($querymaterial)){
		?>
         <option value="<?php echo$resultmaterial["mat_id"]?>"><?php echo $resultmaterial["mat_name"]?></option>
      ><?php
        }
	?>
        
        </select>
	</td>
    </tr>
    <tr>
      <td>จำนวน</td>
      <td>
      <input type="number" name="use_qty" id="use_qty" required="required" /></td>
    </tr>
  </table>
<div style="text-align:center"> <input type="submit" value="เพิ่ม"/> <input type="button" onclick="$('#struc').load('strucmaterial.php?pro_id=<?php echo $_GET['pro_id'] ?>');" value="ยกเลิก"/></div>
</form>
<script> function insertstruc(){
	$.ajax({
		url:"insert_strucmaterial2.php"
		,type:'POST',
		data: $("#frmstruc").serialize()+'&pro_id=<?php echo $_GET['pro_id'] ?>'
		,success: function(msg){
			$("#struc").load('strucmaterial.php?pro_id=<?php echo $_GET['pro_id'] ?>');
			}
		});
	} </script>
